package com.shujia.day19;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

public class Demo02FastJson {
    public static void main(String[] args) throws IOException {


        // TODO 读取JSON文件
        //  1.通过IO流读取所有数据，再将数据传入JSONObject
        BufferedReader bufferedReader = new BufferedReader(new FileReader("src/com/shujia/day19/demo2.json"));
        String allJson = "";
        String readLine=null;
        while ((readLine = bufferedReader.readLine())!=null){
            allJson += readLine;
        }
        bufferedReader.close();

        JSONArray parse = JSONArray.parse(allJson);
        for (int i = 0; i < parse.size(); i++) {
            JSONObject jsonObject = parse.getJSONObject(i);
            System.out.println(jsonObject);
        }



    }
}
